Variate Generation in One Line of Code
نویسنده
چکیده
Alternatively, A random variate with a given non-uniform distribution can often by generated in one assignment statement if a uniform source and some simple functions are available. We review such one-line methods for most of the key distributions. 1 A MODEL OF COMPUTATION Random variate generators that are conceptually simple and quick to program become invariably popular, even if they are not as efficient as some more complicated methods. We explore and survey the simplest end of the spectrum-the generators that can be implemented in one line of code. We assume throughout that an unlimited source of i.i.d. uniform [0, 1J random variates U1 , U2 , ... is available. When discussing one-liners, we must distinguish between two situations: in the ordinary case, each request of a uniform variate is fulfilled by another number from this sequence. In the extended case, we may index our requests by U1 , U2, and so forth, so that repetitions of the same uniform variate within the code are possible. This will be called an extended one-liner. The standard operators +, -, *, / are available, as are mod, round, l.J, sign, r·1, 1.1, sin, cos, exp, log, tan, atan. Many functions may be derived from these using only a constant number of combinations. For example, the indicator function Ix>o is simply Ix>a == 2 sign(x a) -1, and Ia>x>b == (sign(x a) sign(x b))/2. FUrthermore, max is included as max(a, b) == a + (b a)Ib>a . 265 max(a, b) = a ; b + Ia ~ bI . Some may include more complicated functions such as r or (, but these will not be required for the discussion below. One may think of a one-liner as an expression tree in which the leaves are uniform [0,1] random variables or constants, and the internal nodes are the operators or functions in the accepted class of operators, which we shall call F. In a simple one-liner, each leaf has a different uniform random variate associated with it. In an extended one-liner, repetitions may occur. We may put this differently. Each expression may be represented as a directed acyclic graph (or "dag"), in which the leaf nodes contain constants or Ui's, but each Ui occurs only once. If multiple Ui nodes are disallowed, Extended one-liners are implementable by dags, while simple one-liners are implementable by trees. We should point out here that. some smart compilers may transform expressions with repetitions into dags before machine translation. The well-known Box-Muller formula for normal random variates, X == J -2 log U1 cOS(21rU2) , is thus a simple one-liner. However, the equivalent form X == exp( (1/2) log(-2 log U1 )) (cos ( 1rU2 ) sin ( 1rU2)) is an extended one-liner. The figure below depicts the expression trees for both forms of the Box-Muller
منابع مشابه
Fast Generation of Deviates for Order Statistics by an Exact Method
We propose an exact method for generating random deviates from continuous order statistics. This versatile method that generates Beta deviates as a middle step can be applied to any density function without resorting to numerical inversion. We also conduct an exhaustive investigation to document the merits of our method in generating deviates from any Beta distribution.
متن کاملUse of Two Smoothing Parameters in Penalized Spline Estimator for Bi-variate Predictor Non-parametric Regression Model
Penalized spline criteria involve the function of goodness of fit and penalty, which in the penalty function contains smoothing parameters. It serves to control the smoothness of the curve that works simultaneously with point knots and spline degree. The regression function with two predictors in the non-parametric model will have two different non-parametric regression functions. Therefore, we...
متن کاملSecond Generation IMO Intact Stability Vulnerability Criteria and its Application to ships Navigating in Persian Gulf and Oman Sea
Second generation intact stability criteria for few past years had been under development by International Maritime Organization (IMO). Since the draft proposed amendments shall be amended to International code on Intact Stability (IS code 2008), new regulations shall enter into force for ships of length more than 24 meter. Generally second generation intact stability criteria (SGISC) refers to...
متن کاملProduct Line Development using Multiple Domain Specific Languages in Embedded Systems
In model driven development (MDD), much meaning can be given to the model using a domain specific language (DSL), and the code generation rate can be increased. Model-based product line development is possible using code generation to realize variability. In this paper, we describe the development of line tracer robots for a contest, where we achieved a high rate of code generation by using two...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2011